<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>头部</title>
    <style type="text/css">
        .login-user {
            color: #282a3c!important;
            font-size: 15px!important;
            padding-left: 5px;
        }
    </style>
</head>
<body>
<header id="m_header" class="m-grid__item m-header " m-minimize-offset="200" m-minimize-mobile-offset="200">
    <div class="m-container m-container--fluid m-container--full-height">
        <div class="m-stack m-stack--ver m-stack--desktop">
            <div class="m-stack__item m-stack__item--fluid m-header-head" style="box-shadow: none;" id="m_header_nav">
                <!-- BEGIN: Horizontal Menu -->
                <button class="m-aside-header-menu-mobile-close  m-aside-header-menu-mobile-close--skin-light "
                        id="m_aside_header_menu_mobile_close_btn">
                    <i class="la la-close"></i>
                </button>
                <!-- END: Horizontal Menu -->
                <!-- BEGIN: Topbar -->
                <div id="m_header_topbar" class="m-topbar  m-stack m-stack--ver m-stack--general">

                    <div class="m-stack__item m-topbar__nav-wrapper">
                        <ul class="m-topbar__nav m-nav m-nav--inline">
                            <li class="m-nav__item m-topbar__user-profile  m-dropdown m-dropdown--medium m-dropdown--arrow  m-dropdown--align-right m-dropdown--mobile-full-width m-dropdown--skin-light"
                                m-dropdown-toggle="click">
                                <a href="#" class="m-nav__link m-dropdown__toggle">
                                    <span class="m-nav__link-icon m-topbar__usericon">
                                        <span class="m-nav__link-icon-wrapper">
                                            <i class="flaticon-user-ok"></i>
                                        </span>
                                    </span>
                                    <span class="m-topbar__username login-user">
                                        ${user.name}
                                    </span>
                                    <input type="hidden" id="userId" value="${user.id}">
                                </a>
                                <div class="m-dropdown__wrapper" style="width: 180%;">
                                    <span class="m-dropdown__arrow m-dropdown__arrow--right m-dropdown__arrow--adjust"></span>
                                    <div class="m-dropdown__inner">
                                        <div class="m-dropdown__body">
                                            <div class="m-dropdown__content">
                                                <ul class="m-nav m-nav--skin-light">
                                                    <li class="m-nav__item">
                                                        <a href="#" class="m-nav__link" id="editPasswordPage">
                                                            <i class="m-nav__link-icon fa fa-edit"></i>
                                                            <span class="m-nav__link-text">
                                                                修改密码
                                                            </span>
                                                        </a>
                                                    </li>
                                                    <li class="m-nav__separator m-nav__separator--fit"></li>
                                                    <li class="m-nav__separator m-nav__separator--fit"></li>
                                                    <li class="m-nav__item">
                                                        <a href="javascript:void(0);" id="loginOut"
                                                           class="btn m-btn--pill btn-secondary m-btn m-btn--custom m-btn--label-brand m-btn--bolder">
                                                            注销
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
                <!-- END: Topbar -->
            </div>
        </div>
    </div>
</header>
</body>
<script id="passwordHtml" type="text/html">
    <div class="m-form m-form--fit m-form--label-align-right layer-div  layui-form" id="password-form">
        <div class="m-portlet__body">
            <div class="form-group m-form__group row">
                <label class="col-lg-3 col-form-label">
                    原始密码 <font color="red">*</font>
                </label>
                <div class="col-lg-8">
                    <input type="password" id="old_Word"
                           class="form-control " required lay-verify="required" placeholder="请输入原始密码 ">
                </div>
            </div>
            <div class="form-group m-form__group row">
                <label class="col-lg-3 col-form-label">
                    新密码 <font color="red">*</font>
                </label>
                <div class="col-lg-8">
                    <input type="password" id="new_Word"
                           class="form-control " required lay-verify="required" placeholder="请输入新密码">
                </div>
            </div>
            <div class="form-group m-form__group row password">
                <label class="col-lg-3 col-form-label">
                    确认密码 <font color="red">*</font>
                </label>
                <div class="col-lg-8">
                    <input type="password" id="confirm_Word"
                           class="form-control" required lay-verify="required" placeholder="请输入确定密码">
                </div>
            </div>
        </div>
        <div class="m-portlet__foot m-portlet__foot--fit">
            <div class="m-form__actions m-form__actions">
                <div class="row">
                    <div class="col-lg-12 ml-lg-auto">
                        <button id="editCancle" class="btn btn-secondary m--pull-right" style="border-radius: 25px">
                            取消
                        </button>
                        <button id="editYes" lay-submit lay-filter="save_user" class="btn btn-brand m--pull-right">
                            保存
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="application/javascript">
    var localObj = window.location;
    var contextPath = localObj.pathname.split("/")[1];
    var basePath = localObj.protocol + "//" + localObj.host + "/" + contextPath;

    $("#loginOut").on('click', function () {
        logout();
    })

    function logout() {
        $.ajax({
            url: basePath + '/logout',
            type: 'get',
            dataType: 'json',
            success: function (json) {
                if (json.code === 'ok') {
                    window.location.href = basePath + "/loginPage";
                } else {
                    layer.msg('注销失败：' + json.msg, {
                            icon: 2, time: 0, closeBtn: true
                        }
                    );
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                layer.msg('注销失败：' + jqXHR.status, {
                        icon: 2, time: 0, closeBtn: true
                    }
                );
            }
        });
    }
</script>
</html>